#include <sys/wait.h>
#include <stdio.h>
#include <stdlib.h>

#define MAXLINE 4096

void exitPrint(const char *str);
void exitPrint(const char *str){
        printf("%s\n", str);
        exit(0);
}

int main(void){
    char line[MAXLINE];
    FILE *fpin;

    if((fpin = popen("./myuclc", "r")) == NULL){
        exitPrint("popen error");
    }

    for(;;){
        fputs("prompt> ", stdout);
        fflush(stdout);
        if(fgets(line, MAXLINE, fpin) == NULL){
            break;
        }
        if(fputs(line, stdout) == EOF){
            exitPrint("fputs error");
        }
    }
    if(pclose(fpin) == -1){
        exitPrint("pclose error");
    }
    putchar('\n');
    exit(0);
}